<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>


<body>
<table id="abc" border="1"></table>
<input type="button" value="添加行" onclick="addNew()"/>
<input type="button" value="删除行" onclick="del()"/>
</body>
<script>
	
		var bq=document.getElementById("abc");
		for(var i=0;i<3;i++){
			var tr=document.createElement("tr");
			for(var j=0;j<3;j++){
				var td=document.createElement("td");
				td.style.height="30px";
				td.style.width="30px";
				tr.appendChild(td);
				}
		bq.appendChild(tr);
				}
		function addNew(){
				var tr=bq.lastChild.cloneNode(true);
				bq.appendChild(tr);
				}
		function del(){
				if(bq.children.length==1){
					alert("不能刪");
				}
				else{
					bq.removeChild(bq.lastChild);
				}
				
		}
	
</script>
</html>
